﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.SqlClient;



namespace WindowsFormsApp1
{
    class DbHelper

    {
        private static readonly string conString = "server=.;database=Schools;uid=sa;pwd=123456";

        public static DataTable GetDataTable(string sql)
        {
            SqlDataAdapter adapter = new SqlDataAdapter(sql, conString);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            return dt;

        }

        public static int AddOrEdiSave(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
            sqlConnection.Open();
            return sqlCommand.ExecuteNonQuery();
        }
        
         

    }
}
